#!/bin/bash

# 判断参数个数
if [ $# -ne 1 ]; then
    echo "input start | stop!"
    exit
fi

# 启动maxwell
if [ $1 = start ]; then
    if [[ -z $(jps | awk '/Maxwell/{print $1}') ]]; then
        echo "正在启动Maxwell!"
        /usr/local/maxwell/bin/maxwell --config /usr/local/maxwell/config.properties --daemon
        echo "Maxwell已后台启动运行!"
    else
        echo "Maxwell已启动!"
    fi
# 停止maxwell
elif [ $1 = stop ]; then
    if [[ -z $(jps | awk '/Maxwell/{print $1}') ]]; then
        echo "Maxwell已停止!"
    else
        echo "正在停止Maxwell!"
        jps | awk '/Maxwell/{print $1}' | xargs kill -9
        echo "Maxwell已停止运行!"
    fi
else
    echo "input start | stop!"
fi
